package com.zhongying.jf.util.sms253;

import com.alibaba.fastjson.JSON;
import com.zhongying.jf.util.sms253.config.SmsConfig;
import com.zhongying.jf.util.sms253.model.SmsBalanceRequest;
import com.zhongying.jf.util.sms253.model.SmsBalanceResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 余额查询
 */
public class SmsBalanceQueryUtil {

    // 日志记录
    private static final Logger logger = LoggerFactory.getLogger(SmsBalanceQueryUtil.class);


    public static void main(String[] args) {
        SmsBalanceResponse smsBalanceResponse = queryBalance();
        System.out.println("smsBalanceResponse=" + JSON.toJSONString(smsBalanceResponse));
    }

    /**
     * 余额查询
     */
    public static SmsBalanceResponse queryBalance() {
        SmsBalanceRequest smsBalanceRequest = new SmsBalanceRequest(SmsConfig.sms_account, SmsConfig.sms_pwd);
        String requestJson = JSON.toJSONString(smsBalanceRequest);
        logger.info("query balance request param: " + requestJson);
        String response = SmsHttpClient.sendSmsByPost(SmsConfig.smsBalanceRequestUrl, requestJson);
        logger.info("query balance reponse param: " + response);
        SmsBalanceResponse smsVarableResponse = JSON.parseObject(response, SmsBalanceResponse.class);
        logger.info("query balance reponse toString is: " + smsVarableResponse);
        return smsVarableResponse;
    }
}
